<%@page language="java" contentType="text/html;charset=GBK"%>
<%@page import="com.creawor.imei.util.*"%>
<%@page import="com.creawor.hz_market.t_advertisement.*"%>
<%@page import="java.io.*,java.util.*"%>
<%@page import="parse.*,com.jspsmart.upload.SmartUpload"%>

<%
String xmltype = request.getParameter("doctype");
			
			//System.out.println("xmltype="+xmltype+",parameters:"+request.getParameterMap());
			if(xmltype==null)
			{
				xmltype=""+request.getAttribute("doctype");
			}
			//System.out.println("xmltype="+xmltype);
			//System.out.println("name="+request.getUserPrincipal());
InputStream in = null;
//			doctype = request.getParameter("doctype");
//			createDir(doctype);
com.jspsmart.upload.File file = null;
			SmartUpload mySmartUpload = new SmartUpload();
			try {
				mySmartUpload.initialize(config, request, response);
				mySmartUpload.upload();
				file = mySmartUpload.getFiles().getFile(0);
				if(file!=null)
				{
					in = new FileInputStream(file.getFileName());
				}
			} catch (Exception e) {
				try {
				e.printStackTrace();
					request.setAttribute("msg", "Upload error");
					request.getRequestDispatcher("../index/error.jsp").forward(
							request, response);
				} catch (Exception ex) {
				}
			}
		
		
			
			if ("1".equals(xmltype)) {
				BalanceHandle ex=new BalanceHandle();
				//System.out.println("starting....");
				String filepath = request.getParameter("filepath");
				ex.readExcel(filepath);
				ex.insertInfo();
			}
			if ("2".equals(xmltype)) {
				CountyHandle ex = new CountyHandle();
				//System.out.println("starting....");
				String filepath = request.getParameter("filepath");
				ArrayList al = ex.readExcel(filepath);
				ex.insertData(al);
			}
			if ("3".equals(xmltype)) {

			}
			if ("4".equals(xmltype)) {
				ADHandle ex = new ADHandle();
				//System.out.println("starting....");
				String filepath = request.getParameter("filepath");
				ArrayList al = ex.readExcel(in);
				ex.insertData(al);
			}
			if ("5".equals(xmltype)) {
				HallHandle ex = new HallHandle();
				//System.out.println("starting....");
				String filepath = request.getParameter("filepath");
				ex.readExcel(filepath);
				ex.insertInfo();
			}
			if ("6".equals(xmltype)) {
				ChannelHandle ex=new ChannelHandle();
				//System.out.println("starting....");
				String filepath = request.getParameter("filepath");
				ex.readExcel(filepath);
				ex.insertInfo();
			}
			if ("7".equals(xmltype)) {
				GroupHandle ex = new GroupHandle();
				//System.out.println("starting....");
				String filepath = request.getParameter("filepath");
				ArrayList al = ex.readExcel(filepath);
				ex.insertData(al);
			}
			//System.out.println("in the end ....");


%>